/**
*      author: Y_Yao
*      created: 2024-11-17 14:41:09
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;

char change(char a)
{
    if(a >= 'A' && a <= 'Z')
    {
        return a - 'A' + 'a';
    }
    else return a - 'a' + 'A';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    int q;
    cin >> s;
    cin >> q;
    while(q--)
    {
        int i;
        cin >> i;
        i--;
        if(__builtin_popcountll(i / s.size()) % 2 == 1)
        {
            cout << change(s[i % s.size()]) << ' ';
        }
        else cout << s[i % s.size()] << ' ';
    }
    return 0;
}